<template>
  <div class="my-comment">
    <div class="item">
      <div class="top">
        <div class="observer" @click="userSend">
          <img :src="baseUrl + item.author.avatar" alt="" />
        </div>
        <div class="info">
          <div class="up">{{ item.author.nickname }}</div>
          <div class="down">{{ item.created_at | getTime }}</div>
        </div>
        <div class="star">
          {{ item.star }} <i class="iconfont iconbtn_dianzan_big_nor"></i>
        </div>
      </div>
      <div class="middle">{{ item.content }}</div>
      <div class="bottom" v-if="item.children_comments.length != 0">
        <div
          class="repaly"
          v-for="(myitem, myindex) in item.children_comments"
          :key="myindex"
        >
          <span>{{ myitem.author }}: </span>{{ myitem.content }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['item'],
  data () {
    return {
      // 基地址
      baseUrl: process.env.VUE_APP_URL
    }
  },
  methods: {
    userSend () {
      this.$emit('userSend', this.item)
    }
  },
  created () {
    // console.log(this.item)
  }
}
</script>

<style lang="less" scoped>
.my-comment {
  .item {
    margin-bottom: 20px;
    .top {
      display: flex;
      font-size: 12px;
      .observer {
        img {
          width: 35px;
          height: 35px;
          opacity: 1;
          border-radius: 50%;
        }
      }
      .info {
        flex: 1;
        font-size: 12px;
        margin-left: 5px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
      .star {
        line-height: 35px;
      }
    }
    .middle {
      padding: 5px 40px;
      font-size: 16px;
      font-weight: 400;
      line-height: 27px;
    }
    .bottom {
      padding: 10px 0 10px 40px;
      //   padding-left: 40px;
      background-color: #f7f4f5;
      font-size: 14px;
      .repaly {
        padding: 6px 0;
        word-break: break-all; // 作用：单词换行
        word-wrap: break-word; // 作用：特殊字符换行

        span {
          font-weight: 700;
          // float: left; // 文本会给浮动的元素让位置
        }
      }
    }
  }
}
</style>
